<template>
  <!-- 没有图片 -->
  <div
    class="none"
    v-if="data.images.length==0"
  >
    <a :href="`/post/post?id=${data.id}`">
      <div class="head">{{data.title}}</div>
      <div class="foot">{{moment(data.updated_at).format('YYYY-MM-DD HH:mm:ss')}}
        阅读 {{data.watch?data.watch:0}}
      </div>
    </a>
  </div>
  <!-- 一张图片 -->
  <div
    class="one"
    v-else-if="data.images.length>0"
  >
    <a :href="`/post/post?id=${data.id}`">
      <div class="left">
        <img
          :src="data.images[0]"
          alt=""
        >
      </div>
      <div class="right">
        <div class="top">我是标题</div>
        <div class="bottom">{{moment(data.updated_at).format('YYYY-MM-DD HH:mm:ss')}}
          阅读 {{data.watch?data.watch:0}}</div>
      </div>
    </a>
  </div>
</template>

<script>
import moment from "moment";
export default {
  props: ["data"],
  methods: {
    moment,
  },
};
</script>

<style lang="less" scoped>
.none {
  width: 280px;
  height: 80px;
  padding: 20px 0;
  border-bottom: 1px solid #dddddd;
  a {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .head {
      overflow: hidden;
      text-overflow: ellipsis;
      /* 弹性伸缩盒子模型显示 */
      display: -webkit-box;
      /* 限制在一个块元素显示的文本的行数 */
      -webkit-line-clamp: 3;
      /* 设置或检索伸缩盒对象的子元素的排列方式 */
      -webkit-box-orient: vertical;
    }

    .foot {
      font-size: 12px;
      color: #c4a6a6;
    }
  }
}

.one {
  width: 280px;
  height: 80px;
  padding: 20px 0;
  border-bottom: 1px solid #dddddd;
  a {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    .left {
      width: 100px;
      height: 100%;
      img {
        width: 100%;
        height: 100%;
      }
    }

    .right {
      width: 170px;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .top {
        overflow: hidden;
        text-overflow: ellipsis;
        /* 弹性伸缩盒子模型显示 */
        display: -webkit-box;
        /* 限制在一个块元素显示的文本的行数 */
        -webkit-line-clamp: 3;
        /* 设置或检索伸缩盒对象的子元素的排列方式 */
        -webkit-box-orient: vertical;
      }

      .bottom {
        font-size: 12px;
        color: #c4a6a6;
      }
    }
  }
}
</style>